import { createStore } from 'vuex';
import {
	getCartNumber
} from '@/api/product/index.ts'
const store = createStore({
  state: {
    cartCount: 0, // 义购之家购物车数量
  },
  getters: {
    
  },
  mutations: {
    SET_CART_COUNT(state,data: number) {
      state.cartCount = data
    }
  },
  actions: {
	  // 获取义购之家购物车数量
    async getCartNumData({ commit }) {
	   const res = await getCartNumber({
		   numType: true,
		   type: 'total'
	   })
	   if(res.code === 200) {
		   commit('SET_CART_COUNT',res.data.count);
	   }
    }
  }
});

export default store;